package com.collect.tanzania.zhiScene.zhiOrderReview.zhiFollow.bean;

import android.text.TextUtils;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

public class ZHIROrderReviewDetailEntity implements Serializable {

    private ArrayList<ZHIROrderReviewDetailContactEntity> userContacts;
    private ZHIROrderReviewDetailUserEntity user;

    private String applyTime;


    public ArrayList<ZHIROrderReviewDetailContactEntity> getUserContacts() {
        if (user == null) {
            return new ArrayList<>();
        }
        return userContacts;
    }

    public void setUserContacts(ArrayList<ZHIROrderReviewDetailContactEntity> userContacts) {
        this.userContacts = userContacts;
    }

    public ZHIROrderReviewDetailUserEntity getUser() {
        if (user == null) {
            return new ZHIROrderReviewDetailUserEntity();
        }
        return user;
    }

    public void setUser(ZHIROrderReviewDetailUserEntity user) {
        this.user = user;
    }


    public static String formatDate(String inputDateStr) {
        // 原始日期格式
        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault());

        // 输出日期格式
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());

        try {
            // 解析输入的日期字符串
            Date date = inputFormat.parse(inputDateStr);

            // 将日期格式化为所需的输出格式
            if (date != null) {
                return outputFormat.format(date);
            }
        } catch (ParseException e) {
            return null; // 如果解析失败则返回 null
        }
        return null; // 如果解析失败则返回 nullÏ
    }

    public String getApplyTime() {
        if(TextUtils.isEmpty(applyTime)) return null;
        applyTime = formatDate(applyTime);

        return applyTime;
    }

    public void setApplyTime(String applyTime) {
        this.applyTime = applyTime;
    }
}